package com.project.bean;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.List;

/**
 * <p>
 * 订单实体（用户模块）
 * </p>
 *
 * @author lhy
 * @since 2021-10-05
 */
@Data
@EqualsAndHashCode(callSuper = true)
@Accessors(chain = true)
@TableName("sys_order")
public class OrderBean extends Model {

    private static final long serialVersionUID = 1L;

    /**
     * 订单主键（自增）
     */
    @TableId(value = "orderId", type = IdType.AUTO)
    private Integer orderId;

    /**
     * 订单编号（本系统）
     */
    @TableField("orderCode")
    private String orderCode;

    /**
     * 支付订单号（支付前为空）
     */
    @TableField("wxOrderCode")
    private String wxOrderCode;

    /**
     * 下单时间
     */
    @TableField("orderTime")
    private String orderTime = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));

    /**
     * 订单总价
     */
    @TableField("orderMoney")
    private String orderMoney;

    /**
     * 订单状态（
     * 0：已下单，未支付；
     * 1：已下单，已支付，商家未接单；
     * 2：已下单，已支付，商家已接单，骑手未接单；
     * 3：已下单，已支付，商家已接单，骑手已接单，未送达；
     * 4：已下单，已支付，商家已接单，骑手已接单，已送达，用户消费；
     * 5：已下单，已支付，商家已接单，骑手已接单，已送达，用户退款；
     * ）
     */
    @TableField("status")
    private Integer status = 0;

    /**
     * 订单备注
     */
    @TableField("description")
    private String description;

    /**
     * 订单收货地址
     */
    @TableField("receiverAddress")
    private String receiverAddress;

    /**
     * 收货人
     */
    @TableField("receiver")
    private String receiver;

    /**
     * 收货人性别
     */
    @TableField("receiverGentle")
    private String receiverGentle;

    @TableField("receiverPhone")
    private String receiverPhone;

    /**
     * 送达时间
     */
    @TableField("receiveTime")
    private String receiveTime;

    /**
     * 用户外键
     */
    @TableField("userCode")
    private String userCode;

    /**
     * 商户外键
     */
    @TableField("shopCode")
    private String shopCode;

    /**
     * 骑手外键
     */
    @TableField("riderCode")
    private String riderCode;

    /**
     * 骑手姓名
     */
    @TableField("riderName")
    private String riderName;

    /**
     * 订单是否评价（已经评价为1，未评价为0）
     */
    @TableField("orderStarStatus")
    private Integer orderStarStatus = 0;

    /**
     * 退款描述
     */
    @TableField("backMoneyInfo")
    private String backMoneyInfo;

    /**
     * 该订单中包含的商品明细集合
     */
    @TableField(exist = false)
    private List<OrderInfoBean> infoList;

    public OrderBean() {
    }

    public OrderBean(String orderCode, String description, String receiverAddress, String receiver, String receiverGentle, String receiverPhone, String userCode, String shopCode) {
        this.orderCode = orderCode;
        this.description = description;
        this.receiverAddress = receiverAddress;
        this.receiver = receiver;
        this.receiverGentle = receiverGentle;
        this.receiverPhone = receiverPhone;
        this.userCode = userCode;
        this.shopCode = shopCode;
    }
}
